import {HTTP} from '../../utils/http';

const BASE_URL = "HomePage/"

const GET_CAROUSE_PIC = `${BASE_URL}getHomeCarouselPictur`
const GET_COURSE_CA = `${BASE_URL}getCourseCategory`
const GET_NEWS = `${BASE_URL}get_home_news_list`
const GET_SCHOOL = `${BASE_URL}get_school_list`
const GET_TEACHER = `${BASE_URL}get_home_teacher_list`
const GET_STUDENT = `${BASE_URL}get_home_student_list`
const GET_SUBJECT = `${BASE_URL}get_course_list`

class HomeModel extends HTTP {

    constructor() {
        super()
    }

    /**
     * 获取轮播图
     * @returns {Promise<any>}
     */
    getCarousePic() {

        return this.request({
            url: GET_CAROUSE_PIC
        })
    }

    /**
     * 获取首页分类
     * @returns {*|Promise|Promise<any>}
     */
    getCourseCategory() {
        return this.request({
            url: GET_COURSE_CA
        })
    }

    /**
     * 获取首页新闻
     * @param type
     * @param current
     * @param pageSize
     * @returns {*|Promise|Promise<any>}
     */
    getNews(type, current, pageSize) {

        return this._get(GET_NEWS, type, current, pageSize)
    }


    /**
     * 获取首页学校
     * @param type
     * @param current
     * @param pageSize
     */
    getSchool(type, current, pageSize) {

        return this._get(GET_SCHOOL, type, current, pageSize)
    }

    /**
     * 获取首页教师
     * @param type
     * @param current
     * @param pageSize
     */
    getTeacher(type, current, pageSize) {

        return this._get(GET_TEACHER, type, current, pageSize)
    }

    /**
     * 获取首页课程
     * @param type
     * @param current
     * @param pageSize
     */
    getSubject(type, current, pageSize) {
        return this._get(GET_SUBJECT, type, current, pageSize)
    }

    /**
     * 获取首页学生
     * @param type
     * @param current
     * @param pageSize
     */
    getStudent(type, current, pageSize) {
        return this._get(GET_STUDENT, type, current, pageSize)
    }


    _get(url, type, current, pageSize) {
        return this.request({
            url: url,
            data: {
                "type": type,
                "page": current,
                "pagesize": pageSize
            }
        })
    }


}

export {HomeModel}
